package com.demo.controller;

import com.demo.model.Dog;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2023-02-12
 * Time: 17:04
 */
@Controller
public class DogBean {

    //Bean对象设置作用域的两种写法
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    //@Scope("prototype")
    @Bean
    public Dog doDog() {
        Dog dog = new Dog();
        dog.setAge(7);
        dog.setName("旺财");
        dog.setId(1);

        return dog;
    }


}
